package com.platform.module.common.exception;


import com.platform.module.common.base.CodeEnum;

/**
 * @author Long
 **/
public class CommonException extends RuntimeException {

    private final String code;
    private final String msg;

    public CommonException(CodeEnum codeEnum) {
        super(codeEnum.getMsg());
        this.code = codeEnum.getCode();
        this.msg = codeEnum.getMsg();
    }

    public CommonException(CodeEnum codeEnum, Object... msg) {
        super(codeEnum.getMsg().formatted(msg));
        this.code = codeEnum.getCode();
        this.msg = codeEnum.getMsg().formatted(msg);
    }


    public CommonException(CommonResult commonResult) {
        super(commonResult.getMsg());
        this.code = commonResult.getCode();
        this.msg = commonResult.getMsg();
    }


    public String code() {
        return this.code;
    }

    public String msg() {
        return this.msg;
    }

    public String getMsg() {
        return msg;
    }

    public String getCode() {
        return code;
    }
}
